package cn.sfa.service.routine;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * 
 * @ClassName：AssessService
 * @Description：考核记录查询
 * @author：LiXiang
 * @date：2012-4-10 上午10:46:47
 * 
 */
@Service
public class AssessService {

	Logger log = LoggerFactory.getLogger(AssessService.class);

	@Autowired
	NamedParameterJdbcTemplate jdbcTemplate;

	/**
	 * 
	 * @Title: exportassessresult
	 * @author: LiXiang
	 * @Description: 代理人考核查询
	 * @param currentPage
	 * @param numPerPage
	 * @param url
	 * @param dbranchid
	 * @param cbranchid
	 * @param ubranchid
	 * @param agentname
	 * @param agentcode
	 * @param agentlevelcode
	 * @param idno
	 * @param agentstatus
	 * @param exporttype
	 * @param assesstype
	 *            考核类型
	 * @param yearmonth
	 *            时间
	 * @param P_ASSESSRESULT
	 *            是否通过
	 * @param userID
	 * @return
	 * @throws
	 */
	public List<?> exportassessresult(String i_branchid, String i_citycode,
			String i_ubranchid, String i_agentname, String i_agentcode,
			String i_idno, String i_agentlevelcode, String i_agentstatus,
			String i_assesstype, String i_yearmonth, String i_assessresult,
			String P_USERID,Integer P_COUNT) {		 
		String sqlStr = "select * from table(PKG_SFA_ASSESSEXPORT.query_assessdetails("
				+ ":i_branchid,:i_citycode,:i_ubranchid,:i_agentname,:i_agentcode"
				+ ",:i_idno,:i_agentlevelcode,:i_agentstatus,:i_assesstype"
				+ ",:i_yearmonth,:i_assessresult,:P_USERID,:P_COUNT))";
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("i_branchid", i_branchid);
		paramMap.put("i_citycode", i_citycode);
		paramMap.put("i_ubranchid", i_ubranchid);
		paramMap.put("i_agentname", i_agentname);
		paramMap.put("i_agentcode", i_agentcode);
		paramMap.put("i_idno", i_idno);
		paramMap.put("i_agentlevelcode", i_agentlevelcode);
		paramMap.put("i_agentstatus", i_agentstatus);
		paramMap.put("i_assesstype", i_assesstype);
		paramMap.put("i_yearmonth", i_yearmonth);
		paramMap.put("i_assessresult", i_assessresult);
		paramMap.put("P_USERID", P_USERID);
		paramMap.put("P_COUNT", P_COUNT);
		List<?> list=jdbcTemplate.queryForList(sqlStr, paramMap);		 
		return list;
	}
	
	public List<?> assessresulthis(String i_branchid, String i_citycode,
			String i_ubranchid, String i_agentname, String i_agentcode,
			String i_idno, String i_agentlevelcode, String i_agentstatus,
			String i_assesstype, String i_yearmonth, String i_assessresult,
			String P_USERID,Integer P_COUNT) {		 
		String sqlStr = "select * from table(PKG_SFA_ASSESSEXPORT.query_assessdetailshis("
				+ ":i_branchid,:i_citycode,:i_ubranchid,:i_agentname,:i_agentcode"
				+ ",:i_idno,:i_agentlevelcode,:i_agentstatus,:i_assesstype"
				+ ",:i_yearmonth,:i_assessresult,:P_USERID,:P_COUNT))";
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("i_branchid", i_branchid);
		paramMap.put("i_citycode", i_citycode);
		paramMap.put("i_ubranchid", i_ubranchid);
		paramMap.put("i_agentname", i_agentname);
		paramMap.put("i_agentcode", i_agentcode);
		paramMap.put("i_idno", i_idno);
		paramMap.put("i_agentlevelcode", i_agentlevelcode);
		paramMap.put("i_agentstatus", i_agentstatus);
		paramMap.put("i_assesstype", i_assesstype);
		paramMap.put("i_yearmonth", i_yearmonth);
		paramMap.put("i_assessresult", i_assessresult);
		paramMap.put("P_USERID", P_USERID);
		paramMap.put("P_COUNT", P_COUNT);
		List<?> list=jdbcTemplate.queryForList(sqlStr, paramMap);		 
		return list;
	}
	
}
